//
//  MusicTableViewCell.m
//  彩虹儿歌
//
//  Created by SXS on 15/7/1.
//  Copyright (c) 2015年 HelloBaby. All rights reserved.
//

#import "MusicTableViewCell.h"
#import "MusicViewModels.h"
#import "MacroHeader.h"
#import <UIImageView+WebCache.h>

@interface MusicTableViewCell ()



- (void)p_setupSubViews;

@end

@implementation MusicTableViewCell

-(void)dealloc
{
    self.imageV = nil;
    self.nicknameLabel = nil;
    self.personDescribeLabel = nil;
    self.albumsLabel = nil;
    self.fixedLabel = nil;
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self p_setupSubViews];
    }
    return self;
}

- (void)p_setupSubViews
{
    //设置cell图片
    self.backgroundV = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, SCREEN_WIDTH - 20,(SCREEN_HEIGHT - 64)/5 - 10)];
    self.backgroundV.backgroundColor = [UIColor colorWithWhite:1 alpha:0.5];
    
    //添加视图
    CGFloat imageHeight = (SCREEN_HEIGHT - 64)/5 -10;
    CGFloat labelWidth = SCREEN_WIDTH - 35 - imageHeight;
    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0 , 0, imageHeight, imageHeight ) ];
    self.nicknameLabel = [[UILabel alloc] initWithFrame:CGRectMake(15 + imageHeight , 10, imageHeight*2 , imageHeight*4/19 )];
    [self.nicknameLabel setFont:[UIFont systemFontOfSize:15]];
    self.personDescribeLabel = [[UILabel alloc] initWithFrame:CGRectMake(15 + imageHeight , imageHeight*8/19 , labelWidth , imageHeight*4/19 )];
    [self.personDescribeLabel setFont:[UIFont systemFontOfSize:14]];
    self.fixedLabel = [[UILabel alloc] initWithFrame:CGRectMake( 15 + imageHeight , imageHeight* 14 / 19  , 60 , imageHeight *3 / 19)];
    [self.fixedLabel setFont:[UIFont systemFontOfSize:13]];
    self.albumsLabel = [[UILabel alloc] initWithFrame:CGRectMake(75 + imageHeight, imageHeight* 14 / 19 , 30, imageHeight * 3 / 19 )];
    [self.albumsLabel setFont:[UIFont systemFontOfSize:13]];
    
    [self.backgroundV addSubview:self.imageV];
    [self.backgroundV addSubview:self.nicknameLabel];
    [self.backgroundV addSubview:self.personDescribeLabel];
    [self.backgroundV addSubview:self.fixedLabel];
    [self.backgroundV addSubview:self.albumsLabel];
    [self.contentView addSubview:self.backgroundV];
    
    [self.imageV release];
    [self.nicknameLabel release];
    [self.personDescribeLabel release];
    [self.fixedLabel release];
    [self.albumsLabel release];
    [self.backgroundV release];
}

- (void)setModel:(MusicViewModels *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    self.nicknameLabel.text = model.nickname;
    [self.imageV sd_setImageWithURL:[NSURL URLWithString:model.mediumLogo] placeholderImage:[UIImage imageNamed:@"caihong.png"]];
    if (model.personDescribe != nil) {
            self.personDescribeLabel.text = model.personDescribe;
    }
    self.albumsLabel.text = [NSString stringWithFormat:@"%@",model.albums];
    self.fixedLabel.text = @"专辑数";
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
